﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Nhapdiem.aspx.cs" Inherits="webtracuudiem.Nhapdiem" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style2 {
            font-size: x-large;
            color: #FF3300;
            text-align: center;
            background-color: #FF9933;
        }

        .auto-style1 {
            width: 100%;
        }

        .auto-style19 {
        }

        </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="auto-style1">
        <tr>
            <td class="auto-style2" colspan="3"><strong id="labQUANLYDIEM">GIÁO VIÊN NHẬP ĐIỂM</strong></td>
            <td>
                <asp:Button ID="ButThoat" runat="server" Text="Đăng xuất" Width="97px" OnClick="ButThoat_Click" />
            </td>
        </tr>
        <tr>
            <td class="auto-style19" colspan="4">&nbsp;</td>
        </tr>
        <tr>
            <td id="labChonnganh" class="auto-style19">
                &nbsp; Chọn Ngành<br />
                <asp:DropDownList ID="DropChonnganh" runat="server" Height="22px" Width="170px" Style="margin-left: 5px" DataSourceID="chonnganhSourcenhapdiem" DataTextField="TenNganh" DataValueField="MaNganh" AutoPostBack="True" OnSelectedIndexChanged="DropChonnmon_SelectedIndexChanged">
                </asp:DropDownList>
                <asp:SqlDataSource ID="chonnganhSourcenhapdiem" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="SELECT * FROM [NganhHoc]"></asp:SqlDataSource>
                <br />
                <br />
            </td>
            <td id="labLop" class="auto-style19">
                &nbsp;Chọn Lớp<br />
                <asp:DropDownList ID="DropChonlop" runat="server" Height="22px" Width="130px" Style="margin-left: 5px" DataSourceID="chonlopSourcenhapdiem" DataTextField="MaLop" DataValueField="MaLop" OnSelectedIndexChanged="DropChonnmon_SelectedIndexChanged" AutoPostBack="True">
                </asp:DropDownList>
                <asp:SqlDataSource ID="chonlopSourcenhapdiem" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="SELECT * FROM [Lop] WHERE ([MaNganh] = @MaNganh)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropChonnganh" Name="MaNganh" PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                <asp:Label ID="lblthongbao" runat="server"></asp:Label>
           
                <br />
            </td>
            <td id="labChonMon" class="auto-style19">
                &nbsp;Chọn Môn<br />
                <asp:DropDownList ID="DropChonnmon" runat="server" Height="22px" Width="170px" Style="margin-left: 5px" DataSourceID="chonmonSourcenhapdiem" DataTextField="TenMH" DataValueField="MaMH" OnSelectedIndexChanged="DropChonnmon_SelectedIndexChanged" AutoPostBack="True">
                </asp:DropDownList>
                <asp:SqlDataSource ID="chonmonSourcenhapdiem" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>" SelectCommand="SELECT * 
FROM         MonHocCuaNganh INNER JOIN
                      MonHoc ON MonHocCuaNganh.MaMH = MonHoc.MaMH
 WHERE ([MaNganh] = @MaNganh)
">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropChonnganh" Name="MaNganh" PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <br />
            </td>
            <td>
                <asp:Button ID="ButNhapdiem" runat="server" Text="Nhập Điểm" Width="97px" OnClick="ButNhapdiem_Click" />
                <br />
                <asp:Button ID="ButXemĐiem" runat="server" Text="Xem Điểm" Width="97px" OnClick="ButXemĐiem_Click" />
                <br />
                <asp:Button ID="btnAddfilexcel" runat="server" Text="Add File Excel" Width="97px" OnClick="btnAddfilexcel_Click" />
                <asp:Button ID="btnExportExcel" runat="server" OnClick="btnExportExcel_Click" Text="Export Excel" Width="97px" />
            </td>
        </tr>
        <tr>
            <td class="auto-style8" colspan="4">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="MaSV" DataSourceID="nhapdiemSource" Visible="true">
                    <Columns>
                        <asp:BoundField HeaderText="MaSV" DataField="MaSV" ReadOnly="True" SortExpression="MaSV" />
                        <asp:BoundField HeaderText="HoLot" DataField="HoLot" SortExpression="HoLot" />
                        <asp:BoundField HeaderText="Ten" DataField="Ten" SortExpression="Ten" />
                        <asp:TemplateField HeaderText="DiemL1" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:TextBox ID="txtDiemL1" runat="server" Width="35px" Text='<%#Eval("DiemL1") %>' Enabled='<%#Editting%>'  />
                                <asp:CompareValidator runat="server" ControlToValidate="txtDiemL1" Operator="DataTypeCheck" Type="Double" ErrorMessage="*" />
                                <asp:RangeValidator runat="server" ControlToValidate="txtDiemL1"  MaximumValue="10" MinimumValue="0" Type="Double" ErrorMessage="?"/>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="DiemL2" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:TextBox ID="txtDiemL2" runat="server" Width="35px" Text='<%#Eval("DiemL2") %>' Enabled='<%#Editting%>'/>
                                <asp:CompareValidator runat="server" ControlToValidate="txtDiemL2" Operator="DataTypeCheck" Type="Double" ErrorMessage="*" />
                                <asp:RangeValidator runat="server" ControlToValidate="txtDiemL2"  MaximumValue="10" MinimumValue="0" Type="Double" ErrorMessage="?"/>

                                <asp:HiddenField ID="hidenMaSV" runat="server" Value ='<%#Eval("MaSV") %>' />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:BoundField HeaderText="DiemKQ" DataField="DiemKQ" ReadOnly="True"/>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="nhapdiemSource" runat="server" ConnectionString="<%$ ConnectionStrings:Demo1ConnectionString %>"
                    SelectCommand="(SELECT  sv.MaSV,HoLot,Ten, DiemL1=NULL,DiemL2=NULL,DiemKQ=NULL
	FROM SinhVien sv 
	WHERE sv.MaLop=@MaLop  
			AND NOT EXISTS(
					SELECT sv.MaSV,HoLot,Ten,DiemL1,DiemL2,DiemKQ
					FROM Diem d,SinhVien sv 
					WHERE d.MaSV=sv.MaSV AND d.MaMH= @MaMH AND sv.MaLop=@MaLop
				)
)
UNION
(SELECT sv.MaSV,HoLot,Ten,DiemL1,DiemL2 ,DiemKQ
	FROM Diem d,SinhVien sv 
	WHERE d.MaSV=sv.MaSV AND d.MaMH= @MaMH AND sv.MaLop=@MaLop
	)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropChonlop" Name="MALOP" PropertyName="SelectedValue" />
                         <asp:ControlParameter ControlID="DropChonnmon" Name="MAMH" PropertyName="SelectedValue" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="auto-style8" colspan="4">
                <asp:Button ID="btnLuu" runat="server" Text="Lưu lại" Width="97px" OnClick="btnLuu_Click" Visible="False" />
            </td>
        </tr>
    </table>
</asp:Content>
